package com.xumt.hwHMSdemo;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.view.ViewCompat;

import android.accounts.Account;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.Toast;

import com.huawei.hmf.tasks.OnCompleteListener;
import com.huawei.hmf.tasks.OnFailureListener;
import com.huawei.hmf.tasks.OnSuccessListener;
import com.huawei.hmf.tasks.Task;
import com.huawei.hms.common.ApiException;
import com.huawei.hms.support.account.AccountAuthManager;
import com.huawei.hms.support.account.request.AccountAuthParams;
import com.huawei.hms.support.account.request.AccountAuthParamsHelper;
import com.huawei.hms.support.account.result.AuthAccount;
import com.huawei.hms.support.account.service.AccountAuthService;
import com.huawei.hms.support.hwid.HuaweiIdAuthManager;
import com.huawei.hms.support.hwid.request.HuaweiIdAuthParams;
import com.huawei.hms.support.hwid.request.HuaweiIdAuthParamsHelper;
import com.huawei.hms.support.hwid.result.AuthHuaweiId;
import com.huawei.hms.support.hwid.service.HuaweiIdAuthService;
import com.xumt.hwHMSdemo.HMSserver.MyPushService;

public class MainActivity extends AppCompatActivity {
//    private AccountAuthParams mAuthParam;
    public static final String TAG = "HuaweiIdActivity";
    public static final String IS_VIP = "is_vip";
    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        MyPushService.getToken(MainActivity.this);
        Button button=(Button)findViewById(R.id.quite);
        String isvip =getIntent().getExtras().getString(IS_VIP);
        Intent intent=new Intent(this,Login2.class);
        Intent intent1=new Intent(this,CommodityActivity.class);
        Intent intent2=new Intent(this,Locationkit.class);
        Intent intent3=new Intent(this,individualms.class);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Task<Void>signOutTask=Login2.mAuthManager.signOut();
                Login2.mAuthManager=null;
                signOutTask.addOnCompleteListener(new OnCompleteListener<Void>() {
                    @Override
                    public void onComplete(Task<Void> task) {
                        Log.i(TAG,"退出账号成功");
                        Toast.makeText(MainActivity.this,"Quite Access",Toast.LENGTH_SHORT).show();
                    }
                });
                startActivity(intent);

            }
        });

        Button button1=(Button)findViewById(R.id.commodity);
        button1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (isvip.equals("true"))
                {
                    startActivity(intent1);
                    Toast.makeText(MainActivity.this, "welcome VIP！", Toast.LENGTH_SHORT).show();
                }

                else {
                    Toast.makeText(MainActivity.this, "You have to be a VIP！", Toast.LENGTH_SHORT).show();
                }
            }
        });

        Button button2=(Button)findViewById(R.id.storems);
        button2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(intent2);
            }
        });



        Button button3=(Button)findViewById(R.id.individualms);
        button3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(intent3);
            }
        });

    }


    }


